<%@page import="com.project.erp.common.Constants"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/js/erp/ajaxSessionTimeOut.js"></script>
<script type="text/javascript">
$(function() {
	parent.$.messager.progress('close');
	$('#add-parentId').combotree({
        /*required: true,*/
        method: 'POST',
        disabled:true,
        url: contextPath +'/menu/getPrivilegeMenuTree.action'
    });
	
	 $('#form').form({
		url : contextPath+"/menu/editPrivilege.action",
        onSubmit: function(){
        	//检查Form参数合法性,返回false不提交
            if(!checkForm()){
                parent.$.messager.progress('close');
                 return false;
             }
        },
        success : function(data) {
            parent.$.messager.progress('close');
            data = JSON.parse(data);
            if(data && "success" == data.result){
                parent.$.messager.alert('提示信息', data.msg, 'info');
                parent.$.modalDialog.handler.dialog('close');
                parent.$.modalDialog.openner_treeGrid.treegrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
            } else {
                parent.$.messager.alert('错误', data.msg, 'error');
            }
        }
    });
});

function checkForm(){
	var isValid = true;
    var name = $("#form").find("[name='name']").validatebox({
        required: true,
        validType:['length[1,100]']
    });
    isValid = isValid && name.validatebox('isValid');
    
    return isValid;
}
</script>
<div id="add-dialog">  
    <div class="p5">
        <form id="form" name="form" action="" method="post">
            <input id="privilegeId" name="id" type="hidden" value="${privilege.id}"/>
            <ul class="fn-clear" style="margin-left: 40px;"> 
                <li class=""> 
                    <label for="name" class="fl pt3 pl15">名称：</label> 
                    <input name="name" class="w196" type="text" value="${privilege.name}"/>
                </li>
                <li class=""> 
                    <label for="parentId" class="fl pt3">父节点：</label> 
                    <input id="add-parentId" name="parent.Id" style="height: 26px;" value="${privilege.parentId}">
                </li>
                <li class="clear pt10"> 
                    <label for="url" class="fl pt3 pl15 ml-28">URL链接：</label> 
                    <input name="url" class="w196" type="text" value="${privilege.url}"/>
                </li>
                <li class="clear mb5"> 
                    <label for="menu" class="fl pt3 pl15 ml-28">资源类型：</label> 
                    <select id="status-combobox" name="menuType" class="easyui-combobox" style="height: 26px;line-height: 26px;width: 208px;" data-options="editable:false">  
                        <option value="1" <c:if test="${privilege.menuType eq 1}">selected="selected"</c:if>>菜单</option>
                        <option value="2" <c:if test="${privilege.menuType eq 2}">selected="selected"</c:if>>功能</option>
                        <option value="3" <c:if test="${privilege.menuType eq 3}">selected="selected"</c:if>>资源</option>
                    </select> 
                </li>
                <li class="clear">
                   <label for="external" class="fl pt3 pl15 ml-28">扩展资源：</label> 
                   <textarea name="external" class="mt5" style="height: 80px;overflow: auto;line-height: 18px;width: 395px;">${privilege.external}</textarea>
                </li>
            </ul>
            <div class="fn-clear"></div>
        </form>
    </div>
</div> 